/*
 * character.cpp
 * this file contains functions necessary to perform 
 * creation/deletion/etc.
 */

#include <time.h>
#include <stdio.h>
#include <stdlib.h>

#include "character.h"
#include <string.h>

int zeroInput(struct input *input)
{
  input->hairType = 0;
  input->hairColor = 0;
  input->race = 0;
  input->name = NULL;

  return 0;
}

int character::initialize(struct input *input)
{
  srand(time(NULL));        

  if ( !(input->hairColor) )  //if input zero, randomize
    {
      hairColor = rand() % HCMAX;
    }
  else
    {
      hairColor = input->hairColor;
    }
  if ( !(input->hairType) )  //if input zero, randomize
    {
      hairType = rand() % HTMAX;
    }
  else
    {
      hairType = input->hairType;
    }  
  if ( !(input->race) )  //if input zero, randomize
    {
      race = rand() % RMAX;
    }
  else
    {
      race = input->race;
    }
  if (input->name == NULL)
    {
      //generate random name
    }
  else
    {
      name = input->name;
    }

  return 0;
}

void character::print()
{
  printf("%s\n", name);
  for(int i = 0; i < strlen(name); ++i)
    {
      printf("-");
    }
  printf("Hair Color: %d\n", hairColor);
  printf("Hair Type: %d\n", hairType);
  printf("Race: %d\n", race);

  printf("\n");
}
